//************************************************************************
// author	:	vera												
// date		:	2011/4/3 1:28 					                 
//************************************************************************


#ifndef SL_REFERENCED_H_
#define SL_REFERENCED_H_
#include "Config.h"

namespace sl
{

	class SL_EXPORT Referenced
	{
		public:
			Referenced();
			Referenced( const Referenced & );

			// can not understand why do this method
			inline Referenced & operator = ( const Referenced & ) { return *this; };

			// increace the count of the referenced 
			inline void ref();

			// decrease the count of the referenced 
			inline void unref();

			
		protected:
			virtual ~Referenced();
			
			u32		m_nRefCount;

	};

	inline void Referenced::ref()
	{
		++m_nRefCount;
	}

	inline void Referenced::unref()
	{
		if ( --m_nRefCount == 0 )
		{
			delete this;
		}
	}

}


#endif
